agora inbox for [email protected]help / color / mirror / Atom feed
[PATCH v13 8/8] pg_ls_*dir to return all the metadata from pg_stat_file.. 967+ messages / 2 participants [nested] [flat]
* [PATCH v13 8/8] pg_ls_*dir to return all the metadata from pg_stat_file.. @ 2020-03-10 02:56 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Justin Pryzby @ 2020-03-10 02:56 UTC (permalink / raw) ..but it doesn't seem worth factoring out the common bits, since stat_file doesn't return a name, so all the field numbers are off by one. NOTE, the atime is now shown where the mtime used to be. Need catversion bump --- doc/src/sgml/func.sgml | 30 +++++++++----------- src/backend/utils/adt/genfile.c | 29 +++++++++++-------- src/include/catalog/pg_proc.dat | 30 ++++++++++---------- src/test/regress/expected/misc_functions.out | 12 ++++---- src/test/regress/output/tablespace.source | 8 +++--- 5 files changed, 55 insertions(+), 54 deletions(-) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 0763db3f50..a3166aaf54 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -21367,8 +21367,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup()); </entry> <entry><type>setof record</type></entry> <entry> - For each file in the log directory, list the file's name, size, last - modification time, and a boolean indicating if it is a directory. + For each file in the log directory, list the file and its metadata. Access is granted to members of the <literal>pg_monitor</literal> role and may be granted to other non-superuser roles. </entry> @@ -21379,8 +21378,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup()); </entry> <entry><type>setof record</type></entry> <entry> - For each file in the WAL directory, list the file's name, size, last - modification time, and a boolean indicating if it is a directory. + For each file in the WAL directory, list the file and its metadata. Access is granted to members of the <literal>pg_monitor</literal> role and may be granted to other non-superuser roles. </entry> @@ -21391,9 +21389,8 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup()); </entry> <entry><type>setof record</type></entry> <entry> - For each file in the WAL archive status directory, list the file's - name, size, last modification time, and a boolean indicating if it is a - directory. Access is granted to members of the + For each file in the WAL archive status directory, list the file and its metadata. + Access is granted to members of the <literal>pg_monitor</literal> role and may be granted to other non-superuser roles. </entry> @@ -21405,8 +21402,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup()); <entry><type>setof record</type></entry> <entry> For the temporary directory within <parameter>tablespace</parameter>, - list each file's name, size, last modification time, and a boolean - indicating if it is a directory. If <parameter>tablespace</parameter> + list each file and its metadata. If <parameter>tablespace</parameter> is not provided, the <literal>pg_default</literal> tablespace is used. Access is granted to members of the <literal>pg_monitor</literal> role and may be granted to other non-superuser roles. @@ -21492,8 +21488,8 @@ pg_ls_dir_recurse(dir) AS a; </indexterm> <para> <function>pg_ls_logdir</function> lists each file in the log directory, - along with file's size, last modification time, and a boolean - indicating if the file is a directory. By default, only superusers + along with the metadata columns returned by <function>pg_stat_file</function>. + By default, only superusers and members of the <literal>pg_monitor</literal> role can use this function. Access may be granted to others using <command>GRANT</command>. Filenames beginning with a dot and special file types are not shown. @@ -21504,8 +21500,8 @@ pg_ls_dir_recurse(dir) AS a; </indexterm> <para> <function>pg_ls_waldir</function> lists each file in the WAL directory, - along with the file's size, last modification time, and a boolean - indicating if the file is a directory. By default, only superusers + along with the metadata columns returned by <function>pg_stat_file</function>. + By default, only superusers and members of the <literal>pg_monitor</literal> role can use this function. Access may be granted to others using <command>GRANT</command>. @@ -21517,8 +21513,8 @@ pg_ls_dir_recurse(dir) AS a; </indexterm> <para> <function>pg_ls_archive_statusdir</function> lists each file in the WAL - archive status directory, along with the file's size, last modification - time, and a boolean indicating if the file is a directory. By default, only + archive status directory, along with the metadata columns returned by + <function>pg_stat_file</function>. By default, only superusers and members of the <literal>pg_monitor</literal> role can use this function. Access may be granted to others using <command>GRANT</command>. @@ -21531,8 +21527,8 @@ pg_ls_dir_recurse(dir) AS a; <para> <function>pg_ls_tmpdir</function> lists each file in the temporary file directory for the specified <parameter>tablespace</parameter>, along with - its size, last modified time (mtime) and a boolean indicating if the file is a - directory. Directories are used for temporary files shared by parallel + the metadata columns returned by <function>pg_stat_file</function>. + Directories are used for temporary files shared by parallel processes. If <parameter>tablespace</parameter> is not provided, the <literal>pg_default</literal> tablespace is used. By default only superusers and members of the <literal>pg_monitor</literal> diff --git a/src/backend/utils/adt/genfile.c b/src/backend/utils/adt/genfile.c index 21c265aab3..f794352476 100644 --- a/src/backend/utils/adt/genfile.c +++ b/src/backend/utils/adt/genfile.c @@ -578,8 +578,8 @@ pg_ls_dir_files(FunctionCallInfo fcinfo, const char *dir, int flags) while ((de = ReadDir(dirdesc, dir)) != NULL) { - Datum values[4]; - bool nulls[4]; + Datum values[7]; + bool nulls[7]; char path[MAXPGPATH * 2]; struct stat attrib; @@ -613,24 +613,29 @@ pg_ls_dir_files(FunctionCallInfo fcinfo, const char *dir, int flags) continue; } + memset(nulls, 0, sizeof(nulls)); values[0] = CStringGetTextDatum(de->d_name); if (flags & LS_DIR_METADATA) { values[1] = Int64GetDatum((int64) attrib.st_size); - values[2] = TimestampTzGetDatum(time_t_to_timestamptz(attrib.st_mtime)); - if (flags & LS_DIR_ISDIR) - { - values[3] = BoolGetDatum(S_ISDIR(attrib.st_mode)); + values[2] = TimestampTzGetDatum(time_t_to_timestamptz(attrib.st_atime)); + values[3] = TimestampTzGetDatum(time_t_to_timestamptz(attrib.st_mtime)); + /* Unix has file status change time, while Win32 has creation time */ +#if !defined(WIN32) && !defined(__CYGWIN__) + values[4] = TimestampTzGetDatum(time_t_to_timestamptz(attrib.st_ctime)); + nulls[5] = true; +#else + nulls[4] = true; + values[5] = TimestampTzGetDatum(time_t_to_timestamptz(attrib.st_ctime)); +#endif + values[6] = BoolGetDatum(S_ISDIR(attrib.st_mode)); #ifdef WIN32 - /* Links are not directories */ - if (pgwin32_is_junction(path)) - values[3] = BoolGetDatum(false); + /* Links are not directories */ + if (pgwin32_is_junction(path)) + values[6] = BoolGetDatum(false); #endif - } } - memset(nulls, 0, sizeof(nulls)); - tuplestore_putvalues(tupstore, tupdesc, values, nulls); } diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index b3509f0e12..a50742e870 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -10717,42 +10717,42 @@ { oid => '3353', descr => 'list files in the log directory', proname => 'pg_ls_logdir', procost => '10', prorows => '20', proretset => 't', provolatile => 'v', prorettype => 'record', proargtypes => '', - proallargtypes => '{text,int8,timestamptz,bool}', proargmodes => '{o,o,o,o}', - proargnames => '{name,size,modification,isdir}', prosrc => 'pg_ls_logdir' }, + proallargtypes => '{text,int8,timestamptz,timestamptz,timestamptz,timestamptz,bool}', proargmodes => '{o,o,o,o,o,o,o}', + proargnames => '{name,size,access,modification,change,creation,isdir}', prosrc => 'pg_ls_logdir' }, { oid => '3354', descr => 'list of files in the WAL directory', proname => 'pg_ls_waldir', procost => '10', prorows => '20', proretset => 't', provolatile => 'v', prorettype => 'record', proargtypes => '', - proallargtypes => '{text,int8,timestamptz,bool}', proargmodes => '{o,o,o,o}', - proargnames => '{name,size,modification,isdir}', prosrc => 'pg_ls_waldir' }, + proallargtypes => '{text,int8,timestamptz,timestamptz,timestamptz,timestamptz,bool}', proargmodes => '{o,o,o,o,o,o,o}', + proargnames => '{name,size,access,modification,change,creation,isdir}', prosrc => 'pg_ls_waldir' }, { oid => '5031', descr => 'list of files in the archive_status directory', proname => 'pg_ls_archive_statusdir', procost => '10', prorows => '20', proretset => 't', provolatile => 'v', prorettype => 'record', - proargtypes => '', proallargtypes => '{text,int8,timestamptz,bool}', - proargmodes => '{o,o,o,o}', proargnames => '{name,size,modification,isdir}', + proargtypes => '', proallargtypes => '{text,int8,timestamptz,timestamptz,timestamptz,timestamptz,bool}', + proargmodes => '{o,o,o,o,o,o,o}', proargnames => '{name,size,access,modification,change,creation,isdir}', prosrc => 'pg_ls_archive_statusdir' }, { oid => '5029', descr => 'list files in the pgsql_tmp directory', proname => 'pg_ls_tmpdir', procost => '10', prorows => '20', proretset => 't', provolatile => 'v', prorettype => 'record', proargtypes => '', - proallargtypes => '{text,int8,timestamptz,bool}', proargmodes => '{o,o,o,o}', - proargnames => '{name,size,modification,isdir}', prosrc => 'pg_ls_tmpdir_noargs' }, + proallargtypes => '{text,int8,timestamptz,timestamptz,timestamptz,timestamptz,bool}', proargmodes => '{o,o,o,o,o,o,o}', + proargnames => '{name,size,access,modification,change,creation,isdir}', prosrc => 'pg_ls_tmpdir_noargs' }, { oid => '5030', descr => 'list files in the pgsql_tmp directory', proname => 'pg_ls_tmpdir', procost => '10', prorows => '20', proretset => 't', provolatile => 'v', prorettype => 'record', proargtypes => 'oid', - proallargtypes => '{oid,text,int8,timestamptz,bool}', proargmodes => '{i,o,o,o,o}', - proargnames => '{tablespace,name,size,modification,isdir}', + proallargtypes => '{oid,text,int8,timestamptz,timestamptz,timestamptz,timestamptz,bool}', proargmodes => '{i,o,o,o,o,o,o,o}', + proargnames => '{tablespace,name,size,access,modification,change,creation,isdir}', prosrc => 'pg_ls_tmpdir_1arg' }, { oid => '5032', descr => 'list directory with metadata', proname => 'pg_ls_dir_metadata', procost => '10', prorows => '20', proretset => 't', provolatile => 'v', prorettype => 'record', proargtypes => 'text bool bool', - proallargtypes => '{text,bool,bool,text,int8,timestamptz,bool}', proargmodes => '{i,i,i,o,o,o,o}', - proargnames => '{dirname,missing_ok,include_dot_dirs,name,size,modification,isdir}', + proallargtypes => '{text,bool,bool,text,int8,timestamptz,timestamptz,timestamptz,timestamptz,bool}', proargmodes => '{i,i,i,o,o,o,o,o,o,o}', + proargnames => '{dirname,missing_ok,include_dot_dirs,name,size,access,modification,change,creation,isdir}', prosrc => 'pg_ls_dir_metadata' }, { oid => '8511', descr => 'list all files in a directory recursively', proname => 'pg_ls_dir_recurse', prorows => '10000', proretset => 't', provolatile => 'v', prorettype => 'record', proargtypes => 'text', - proallargtypes => '{text,text,int8,timestamptz,bool}', - proargnames => '{dirname,name,size,modification,isdir}', proargmodes => '{i,o,o,o,o}', - prolang => 'sql', prosrc => "with recursive ls as (select * from pg_ls_dir_metadata(dirname, true, false) union all select ls.name||'/'||a.name, a.size, a.modification, a.isdir from ls, pg_ls_dir_metadata(dirname||'/'||ls.name, false, false)a where ls.isdir) select * from ls" }, + proallargtypes => '{text,text,int8,timestamptz,timestamptz,timestamptz,timestamptz,bool}', + proargnames => '{dirname,name,size,access,modification,change,creation,isdir}', proargmodes => '{i,o,o,o,o,o,o,o}', + prolang => 'sql', prosrc => "with recursive ls as (select * from pg_ls_dir_metadata(dirname, true, false) union all select ls.name||'/'||a.name, a.size, a.access, a.modification,a.change,a.creation,a.isdir from ls, pg_ls_dir_metadata(dirname||'/'||ls.name, false, false)a where ls.isdir) select * from ls" }, # hash partitioning constraint function { oid => '5028', descr => 'hash partition CHECK constraint', diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out index ae8716a83f..5614e564bd 100644 --- a/src/test/regress/expected/misc_functions.out +++ b/src/test/regress/expected/misc_functions.out @@ -157,8 +157,8 @@ select count(*) > 0 as ok from (select pg_ls_waldir()) ss; -- Test not-run-to-completion cases. select * from pg_ls_waldir() limit 0; - name | size | modification | isdir -------+------+--------------+------- + name | size | access | modification | change | creation | isdir +------+------+--------+--------------+--------+----------+------- (0 rows) select count(*) > 0 as ok from (select * from pg_ls_waldir() limit 1) ss; @@ -204,8 +204,8 @@ select count(*) > 0 from -- This tests the missing_ok parameter, which causes pg_ls_tmpdir to succeed even if the tmpdir doesn't exist yet -- The name='' condition is never true, so the function runs to completion but returns zero rows. select * from pg_ls_tmpdir() where name='Does not exist'; - name | size | modification | isdir -------+------+--------------+------- + name | size | access | modification | change | creation | isdir +------+------+--------+--------------+--------+----------+------- (0 rows) -- Check that we at least succeed in recursing once, and that we don't show the leading dir prefix @@ -218,8 +218,8 @@ SELECT name, isdir FROM pg_ls_dir_recurse('.') WHERE isdir AND name~'^pg_wal'; -- Check that expected columns are present SELECT * FROM pg_ls_dir_recurse('.') LIMIT 0; - name | size | modification | isdir -------+------+--------------+------- + name | size | access | modification | change | creation | isdir +------+------+--------+--------------+--------+----------+------- (0 rows) -- diff --git a/src/test/regress/output/tablespace.source b/src/test/regress/output/tablespace.source index ba9a3fe29a..1e1e02b589 100644 --- a/src/test/regress/output/tablespace.source +++ b/src/test/regress/output/tablespace.source @@ -17,15 +17,15 @@ CREATE TABLESPACE regress_tblspace LOCATION '@testtablespace@'; -- The name='' condition is never true, so the function runs to completion but returns zero rows. -- The query is written to ERROR if the tablespace doesn't exist, rather than silently failing to call pg_ls_tmpdir() SELECT c.* FROM (SELECT oid FROM pg_tablespace b WHERE b.spcname='regress_tblspace' UNION SELECT 0 ORDER BY 1 DESC LIMIT 1) AS b , pg_ls_tmpdir(oid) AS c WHERE c.name='Does not exist'; - name | size | modification | isdir -------+------+--------------+------- + name | size | access | modification | change | creation | isdir +------+------+--------+--------------+--------+----------+------- (0 rows) -- This tests the missing_ok parameter. If that's not functioning, this would ERROR if the logdir doesn't exist yet. -- The name='' condition is never true, so the function runs to completion but returns zero rows. SELECT * FROM pg_ls_logdir() WHERE name='Does not exist'; - name | size | modification | isdir -------+------+--------------+------- + name | size | access | modification | change | creation | isdir +------+------+--------+--------------+--------+----------+------- (0 rows) -- try setting and resetting some properties for the new tablespace -- 2.17.0 --E0h0CbphJD8hN+Gf-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i); +CREATE INDEX ptnowner_i_idx ON ptnowner(i); +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1); +CREATE ROLE regress_ptnowner; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- 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-03-10 02:56 [PATCH v13 8/8] pg_ls_*dir to return all the metadata from pg_stat_file.. Justin Pryzby <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression 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